﻿function ValueFl(el) {
    if (el == undefined)
        return NOT_VALUE
    else
        return typeof (el) == "number" ? el : el ["ValueFl"]
}

function jCalcNotBalance(arData) {
    arNotBalance[7] = (arNotBalance[0] - arNotBalance[1] - ValueFl (arData[42])) / arNotBalance[0] * 100
}

function jCalcF1(arData) {
    var bCalc
    var i, res = 0

    for (i = 0; i < 6; i++) {
        bCalc = true
        for (j = 0; j < 6; j++) {
            if (ValueFl (arData[(i * 6) + j]) == NOT_VALUE) {
                bCalc = false
                break
            }
        }

        if (bCalc)
            res += ValueFl(arData[(i * 6) + 0]) * (ValueFl (arData[(i * 6) + 2]) - ValueFl(arData[(i * 6) + 3]))
    }
    res += ValueFl (arData[42]) * (arNotBalance[3] - ValueFl (arData[43]))
    res /= 1000

    return res
}

function jCalcF2(arData) {
    var bCalc
    var i, res = 0

    for (i = 0; i < 6; i++) {
        bCalc = true
        for (j = 0; j < 6; j++) {
            if (ValueFl (arData[(i * 6) + j]) == NOT_VALUE) {
                bCalc = false
                break
            }
            else
                ;
        }

        if (bCalc)
            res += ValueFl (arData[(i * 6) + 0]) *
                (
                    ValueFl (arData[(i * 6) + 2]) -
                    ValueFl (arData[43])
                ) -
                ValueFl (arData[(i * 6) + 1]) *
                (
                    ValueFl (arData[(i * 6) + 3]) -
                    ValueFl (arData[43])
                )
        else
            ;
    }
    res -= ValueFl (arData[42]) * ValueFl (arData[43])
    res /= 1000

    return res
}